<?php
/**
 * GenerateRandom Action Helper
 *
 * @desc Cria uma string randômica
 * @uses Zend_Controller_Action_Helper
 */
class Zend_Controller_Action_Helper_BvbGrid
    extends Zend_Controller_Action_Helper_Abstract {

    public $pluginLoader;

    /**
    * Constructor: initialize plugin loader
    *
    * @return void
    */
    public function __construct() {
        $this->pluginLoader = new Zend_Loader_PluginLoader ();
    }
 
    /**
    * grid
    *
    * @desc Cria o objeto Bvb_Grid
    * @param zend_db_table $model
    * @param string $id
    * @return Bvb_Grid
    */
    public function grid($model,$id='')
    {
        $view = new Zend_View(); 
        $config = new Zend_Config_Ini(CONFIG_PATH.'/grid.ini', 'production');
        $grid = Bvb_Grid::factory('Table', $config, $id);
        $grid->setEscapeOutput(false); 
        $grid->setExport(array('pdf', 'print', 'wordx','word','excel')); 
        $grid->setView($view); 
        
        $grid->setSource(new Bvb_Grid_Source_Zend_Table($model));
        
        $grid->addFiltersRenderDir('My/Filters/Render/', 'My_Filters_Render');
        
        $translator = Zend_Registry::get('Zend_Translate');
        $grid->setTranslator($translator);
        
        $form = new Bvb_Grid_Form();
        $form->setAdd(true)->setEdit(true)->setDelete(true)->setAddButton(true);
        $grid->setDeleteConfirmationPage(true);
        $grid->setForm($form);
        return $grid;
    }

}